<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Upload extends CI_Controller 
{
    private static $data = array();
    public $upload;
    public function __construct()
    {
        parent::__construct();
        $this->load->model('Collect_model','collect_model');//用户收藏模型
        require '/application/libraries/alOss/samples/Common.php';
        $this->upload=new Common();
    }
    //上传
    public function upload(){
        //$this->load->library('alOss/samples/Common');
        $dir=date('Ym').'/'.date('d').'/';
        $res=$this->upload->do_upload($dir);
        echo json_encode($res);
    }
    //输入富文本编辑器需要的图片上传格式数据
    public function editUpload(){
        $dir=date('Ym').'/'.date('d').'/';
        $res=$this->upload->do_upload($dir);
        if($res['code']==200){
            $data=[
                'code'=>0,
                'msg'=>'上传成功',
                'data'=>['src'=>IMAGEHOST.$res['content']['url']],
            ];
        }else{
            $data=[
                'code'=>1,
                'msg'=>'上传失败',
                'data'=>['src'=>''],
            ];
        }
        echo json_encode($data);
    }
    //删除
    public function del(){
        $obj='';        //要删除的对象
        $res=$this->upload->del($obj);
    }
}
